#pragma once

class CFont
{
	CMpqFile* m_fontFile;
	HANDLE hRessource;
	LPD3DXFONT m_pFont;
	HFONT m_orgFont;

	std::string m_mpqName;

	float m_aspX, m_aspY;

	ID3DXSprite* m_pSprite;

	void CreateFont(ui32 wdt, ui32 ht, bool bold);
	std::string m_name;
public:
	CFont(std::string szMpq, std::string szFontName, ui32 width = 10, ui32 height = 20, bool bold = false);
	~CFont();
	void DrawTextA(ui32 x, ui32 y, ui32 w, ui32 h, std::string szText, DWORD dwColor = 0xFFFFFFFF, ui32 format = 0);
	void DrawTextW(ui32 x, ui32 y, ui32 w, ui32 h, std::wstring wszText, DWORD dwColor = 0xFFFFFFFF);
	void BatchDrawTextA(ui32 x, ui32 y, ui32 w, ui32 h, std::string szText, DWORD dwColor, ui32 format, ID3DXSprite* sprite);
	void BatchDrawTextW(ui32 x, ui32 y, ui32 w, ui32 h, std::wstring szText, DWORD dwColor, ui32 format, ID3DXSprite* sprite);
	ui32 GetFontHeight(bool asp = false);
	ui32 GetFontWidth(bool asp = false);
	ui32 GetCharWidth(char val, bool asp = false);
	ui32 GetCharWidthW(wchar_t val);

	ui32 GetTextLen(std::string szText, bool asp = false);
	ui32 GetTextLenW(std::wstring wszText, bool asp = false);
	ui32 GetMultiLineHeight(const std::string& szText, ui32 width, bool asp = false);

	float GetXAspect() { return m_aspX; }
	float GetYAspect() { return m_aspY; }

	void Recreate();
	void Release();
};